﻿@{
    ViewData["Title"] = "添加新闻分类";
    Layout = "_layout";
    var NewType = ViewBag.NewType as List<BuyWithoutLoseMoney.Core.Models.NewsType>;
}
@model List<BuyWithoutLoseMoney.Core.Models.NewsType>
    <div>
        <div class="layui-card">
            <div class="layui-card-header">添加产品分类</div>
            <div class="layui-card-body">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <label class="layui-form-label">分类名字</label>
                        <div class="layui-input-block">
                            <input type="text" name="Name" required lay-verify="required" placeholder="请输入分类名字" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">创建时间</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input" name="CreateTime" id="ID-laydate-type-datetime1" placeholder="请选择创建时间">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit lay-filter="addForm">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    @section Scripts{
    <script>
        layui.use(["form", 'layer', 'laydate'], function () {
            var form = layui.form;
            var $ = layui.$;
            var layer = layui.layer;
            var laydate = layui.laydate;
            laydate.render({
                elem: '#ID-laydate-type-datetime1',
                type: 'datetime'
            });
            //提交
            form.on('submit(addForm)', function (data) {
                $.post("/admin/newtype/create", data.field, function (res) {
                    if (res.isSuccess) {
                        layer.msg(res.msg, function () {
                            parent.window.location.href = "/admin/newtype/index";
                        });
                    } else {
                        layer.msg(res.msg);
                    }
                });
                return false;
            });
        })
    </script>
}